<?php defined('SYSPATH') or die('No direct script access.');

class debug {
	public static function printStackTrace($stack = null) {
		if ($stack == null) {
			// $stack = debug_backtrace();
			debug_print_backtrace();
			return;
		}
		$output = '<ol>';
		foreach($stack as $entry) {
			$output .= '<li>';
			$output .= '<dl>';
			$output.="<dt>File:</dt><dd>" . $entry['file']." (Line: ".$entry['line'].")</dd>";
			$output.="<dt>Function:</dt><dd>" . $entry['function']."</dd>";
			// $output.="<dt>Args:</dt><dd>" . var_dump($entry['args']) . "</dd>";
			$output .= '</dl>';
			$output .= '</li>';
		}
		$output .= '</ol>';
		echo $output;
	}

	/** Just for debugging purposes. */
	public static function dump($variable) {
		echo '<pre>' . print_r($variable, true) . '</pre>';
	}
}